package com.psa.system;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.webkit.WebSettings;
import android.webkit.WebView;
import com.psa.tool.ExitApplication;
import com.psa.tool.SystemStatus;
import com.wxw.BaseLibrary.drawable.LayoutParamTool;
import com.wxw.BaseLibrary.tool.ActivityTool;

/**
 * @author david
 */
public class WebViewer extends Activity {
    private WebView webView;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ExitApplication.getInstance().addActivity(this);
        ActivityTool.hideTitle(this);
        ActivityTool.fullScreen(this);
        webView = new WebView(this);
        setSettings(webView);
        addContentView(webView, LayoutParamTool.createMatchParams(5));
        webView.loadUrl(SystemStatus.POP_PICTURES_URL + "/h/mymap.html?a=" + SystemStatus.currentUser.getCorp());
    }

    public static void setSettings(WebView webView) {
        WebSettings webSettings = webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setUseWideViewPort(true);
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setSupportZoom(true);
        webSettings.setBuiltInZoomControls(true);
        webSettings.setDisplayZoomControls(false);

        webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
        webSettings.setLoadsImagesAutomatically(true);
        webSettings.setDefaultTextEncodingName("utf-8");
//        webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
//        webView.setInitialScale(100);
    }
}
